<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播停止</title>
</head>
<body>

<input id="imag" type="image" src="../img/banner_1.jpg" width="100%">

</body>
</html>
<script>
    //6. 点击一下图片，轮播停止，再点击一下图片，轮播继续......
    var imag = document.getElementById("imag");
     var number = 1;
    function f() {
        number++;
        if (number > 4) {
            number = 1;
        }
        imag.src ="../img/banner_" + number + ".jpg"
    }
    var interval = setInterval(f,1000);

    var flag=true;
    imag.onclick=function () {
        if (flag) {
            clearInterval(interval);
            flag=false;
        }else{
          interval =  setInterval(f, 1000);
            flag=true;
        }
    }


</script>